import request from '@/utils/request'

// 1. 获取文章列表
export const getArticleList = ({ current, pageSize }) => {
  return request.get('/admin/interview/query', {
    params: {
      current,
      pageSize
    }
  })
}

// 2. 添加文章
export const addArticle = ({ stem, content }) => {
  return request.post('/admin/interview/create', {
    stem,
    content
  })
}

// 3. 删除文章
// post put ... {}
// get delete
/*
 注意: get delete请求
 如果是query传参:
 - { params:{id}}
 如果是body传参:
 - { data: {id}}
*/
export const delArticle = (id) => {
  return request.delete('/admin/interview/remove', {
    // params: { id }
    data: { id }
  })
}

// 4. 获取文章详情
export const getArticleDetail = (id) => {
  return request.get('/admin/interview/show', {
    params: { id }
  })
}

// 5. 修改面经
export const updateArticle = ({ id, stem, content }) => {
  return request.put('/admin/interview/update', {
    id,
    stem,
    content
  })
}
